import { createApp } from 'vue'
import { createRouter, createWebHistory, Router } from 'vue-router'
import { allRoutes } from '@/config/router_config/all_routes'

/**
 * 生成移动端专属的router路由
 */
function createWindRouter (): Router {
  return createRouter({
    history: createWebHistory(),
    routes: allRoutes
  })
}

function handleRouter (router : Router) {
  router.beforeEach((to, from, next) => {
    next()
  })
}
/**
 * 安装路由插件
 * @param app 要安装的vue应用
 */
function installRouter (app: ReturnType<typeof createApp>) {
  const windRouter = createWindRouter()
  handleRouter(windRouter)
  app.use(windRouter)
}

export default installRouter
